<template><!--预算编制-->
  <el-scrollbar height="690px">
    <div style="display: flex;">
      <div style="width: 15%;border-right: #1a1a1a solid 1px">
        <div style="text-align: center;padding:15px 30px;">全部部门</div>
        <div style="padding: 1px 10px 0px 10px">
          <el-input
              v-model="input2"
              class="w-50 m-2"
              placeholder="Please Input"
              :suffix-icon="Search"
          />
          <el-menu v-if="d.bm.length > 0"
                   :v-model="ys.deptName"
          >
            <el-menu-item
                :label="a.value"
                v-for="a in d.bm"
                :key="a.key"
                :value="a.value" @click="aa(a.value)">{{a.value}}</el-menu-item>

          </el-menu>

        </div>
      </div>

      <div style="width: 84%;">
        <div>
          <div style="margin-left: 20px;font-size: 20px;margin-top: 50px">
            {{ys.deptName}}
          </div>
          <div style="display: flex;margin-left: 820px">
            <el-upload
                class="upload-demo"
                multiple=""
                method="post"
                action="  http://localhost:3688/financeOa/budget/daoru"
                style="margin-left: 10px"
                accept=".xlsx,.xls"
                :show-file-list="false"
                :on-success="success"
                name="files"
            >
              <el-button type="primary">导入</el-button>
            </el-upload>
          </div>
          <div>
            <el-table :data="d.tableData" style="width: 100%;margin-top: 20px;height: 400px"
                      :header-cell-style="{background:'#F5F7FA'}"
                      ref="multipleTableRef"

                      @selection-change="handleSelectionChange"
                      stripe>
              <el-table-column align="center" label="所属部门" width="150" property="deptName"/>
              <el-table-column align="center"  label="预算科目" width="150" property="budgetKm"/>
              <el-table-column align="center"  label="年度" width="150" property="budgetYear"/>
              <el-table-column align="center"  label="期间值" width="150" property="budgetMonth"/>
              <el-table-column align="center"  label="预算初始额" width="150" property="budgetCsmoney"/>
              <el-table-column align="center" label="预算剩余额" width="150" property="budgetSymoney"/>
              <el-table-column align="center"  label="预算状态" width="150" property="budgetState"/>
              <el-table-column align="center"  label="创建者" width="150" property="empName"/>


            </el-table>
            <div>
              <el-row justify="center">
                <el-col>
                  <el-pagination
                      v-model:currentPage="pageNo"
                      v-model:page-size="pageSize"
                      :page-sizes="[5,10, 20, 30, 40]"
                      :small="small"
                      :disabled="disabled"
                      :background="background"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="d.total"
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                  />
                </el-col>
              </el-row>
            </div>
          </div>

        </div>
      </div>
    </div>
  </el-scrollbar>
</template>

<script lang="ts" setup>
import * as echarts from "echarts";
import {Search} from "@element-plus/icons-vue"
import {useStore} from "vuex";
import moment from "moment"
import {onBeforeMount, reactive, ref, toRefs} from "vue";
import type {FormInstance, FormRules, UploadInstance, UploadProps, UploadRawFile} from 'element-plus'
import axios from 'axios'
import {genFileId} from "element-plus";

const d = reactive({
  //table当前展示的数据
  list:null,
  //总记录
  total:0,
  //页码
  pageNo:1,
  //页大小
  pageSize:10,
  //表格数据
  bm:[{key:'1',value:'财务部'},{key:'2',value:'后勤部'},{key:'3',value:'技术部'}],
  tableData:[],
  dialogFormVisible: false
});
let ys=reactive({
  deptName:'后勤部',
})




const ii=ref([])
console.log(ii)
const url="financeOa/budget/daoru"
const action1=()=>{
  console.log(handleExceed)

}

//导入
const upload = ref<UploadInstance>()

const handleExceed: UploadProps['onExceed'] = (files) => {
  upload.value!.clearFiles()
  const file = files[0] as UploadRawFile
  file.uid = genFileId()
  upload.value!.handleStart(file)
}
const submitUpload = () => {
  upload.value!.submit()
}

//查询
const ALltableData=ref([])

const getTabelData=()=>{//分页，这里没必要管一样就行
  let data =JSON.parse(JSON.stringify(ALltableData.value));//把数据转为JSON格式
  let shu = data.splice(
      (d.pageNo - 1) * d.pageSize,
      d.pageSize
  )
  d.tableData = shu ;
}

const handleSizeChange = (val: number) => {//分页，这里没必要管一样就行
  d.pageSize = val ;
  d.pageNo = 1;
  getTabelData();
}

const handleCurrentChange = (val: number) => {//分页，这里没必要管一样就行
  console.log("翻页，当前为第几页", val)
  d.pageNo = val;
  getTabelData();
}

const GetData = ()=>{
  console.log()
  axios.post("financeOa/ysgl/allBudget",ys).then((res)=>{
    console.log(res.data.data)
    //分页开始
    var data =res.data.data;//存入查询出来的所有数据
    ALltableData.value = data;//放入表格
    d.total = res.data.data.length;//获得它的长度
    getTabelData();//调用方法
    d.tableData = res.data.data
    //分页结束

  }).catch()
}
//测试
const  aa=(val)=>{
  ys.deptName=val;
  GetData();
}
onBeforeMount(()=>{
  GetData();
})
const {total, pageNo, pageSize, tableData, dialogFormVisible} = toRefs(d);
</script>

<style>
svg{
  margin-right: 5px;
}
#container{
  box-sizing: border-box;
  height: 100%;
  width: 100%;
  margin: 0 auto;
}
.nian{
  padding:4px 30px 4px 20px;
  display: flex
}
.nian div{
  margin: 10px ;
}
.tian{
  width: 50%;
  text-align: center;
}
.biao{
  padding: 10px;border-bottom: 1px solid #1a1a1a;
}
.el-calendar__header{
  padding: 12px 0px;
}
.jia{
  display: flex;
  justify-content: center;
  margin: 40px 10px 20px 20px;
}
.zi{
  text-align: center;line-height: 100px;width: 100px
}
.cc{
  width: 30%;
  padding: 5px 5px;
}
.cc div{
  text-align: center;
  padding: 18px 0px;
}
.el-tabs__header{
  margin: 0px;
}
.el-tabs__nav{
  margin-left: 30px;
  padding: 6px 5px;
}
.el-tabs__item{
  font-size: 16px;
}
.hotitle{
  background: #DCEFF8;
  padding: 10px 12px;
}
.ho{
  padding: 12px 12px;
  font-size: 14px;
  display: flex;
}
.hodiv{
  display: flex;padding: 20px 3px;
}
.hodivv{
  margin: 20px;
}
.hodivvcount{
  width: 50px;flex:1;text-align: right
}
.el-button-group{
  display: flex;
  justify-content: flex-start;
}
.you{
  display: flex;padding: 12px 12px;
  font-size: 14px;
}
.handsome{
  display: flex;margin-top: 15px
}
.icondiv{
  display: flex;margin: 0px 10px
}
.tableicon{
  margin-right: 5px;
}
</style>